/*
*   pcb.c
*   Authors: Dustin Striplin
*   Contains all of the basic information about a process, also contains a pointer to the process
*/

#include <stdlib.h>

#include "pcb.h"

PCBPtr pcbConstructor(int pid, ProcessPtr proc) {
    PCBPtr toReturn = (PCBPtr) malloc(sizeof(PCBStr));
    toReturn->pid = pid;
    toReturn->state = READY;
    toReturn->process = proc;

    //function pointer
    toReturn->destruct = pcbDestructor;
    toReturn->step = pcbStep;

    return toReturn;
}


void pcbDestructor(PCBPtr this) {
    free(this);
}

/*
* next instruction is executed. After the predetermined number of steps have run
*   the next request will be executed.
*   returns: the request
*/
RequestPtr pcbStep(PCBPtr this) {
    return this->process->step(this->process);
}
